#!/usr/bin/python
#send eml file using python

SMTP=("192.168.1.99", 25)
HELO="HELO c\r\n"
MAILFROM="MAIL FROM:<micwho@localhost.localdoamin>\r\n"
RCPTTO="RCPT TO:<micwho@qq.com>\r\n"
DATA="DATA\r\n"

import socket
import sys

if len(sys.argv) < 2:
	print 'Usage with eml file'

f = open(sys.argv[1], "r")
content=f.read()

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(SMTP)

data = client.recv(1024)
print data

client.send(HELO)
print HELO
data = client.recv(1024)
print data

client.send(MAILFROM)
print MAILFROM
data = client.recv(1024)
print data

client.send(RCPTTO)
print RCPTTO
data = client.recv(1024)
print data

client.send(DATA)
print DATA
data = client.recv(1024)
print data

client.send(content)
client.send("\r\n.\r\n")
print "send eml content\n"
data = client.recv(1024)
print data

print "QUIT\n"
client.send("QUIT\r\n")
data = client.recv(1024)
print data

client.close()
f.close()